#ifndef _TG_NET_PACKET_H_DEFINE__
#define _TG_NET_PACKET_H_DEFINE__

#include "TG_TYPE.h"


//local 1000M
//#define NET_PACKET_SIZE	     8148/16*16   //(8192-8-20)-16
//local 100M
//#define NET_PACKET_SIZE	     1456/16*16   //(1500-8-20)-16
//#define NET_PACKET_SIZE	     1400
//wan
//udp
//#define NET_PACKET_SIZE	     532  //(576-8-20)-16
//tcp
#define NET_PACKET_SIZE	         520  //(576-20-20)-16


//
#define DD_WAITTIME   5000

/************************************************************************
*�����ʽ
*���� nMsgType < 0xff,  _eTG_FRAME_TYPE 
*���� nMsgType > 0xff,  command 
************************************************************************/


/*���漸����Ҫ������ͨ�ŵ�*/
#define MSG_TYPE_LOGIN                  0xA000
#define MSG_TYPE_REALSTREAM             0xA100    //
#define MSG_TYPE_TALK                   0xA200    //
#define MSG_TYPE_BROADCAST              0xA300    //
#define MSG_TYPE_AUTOSEARCH             0xA400    //
#define MSG_TYPE_FILE                   0xA500    //


//#include "TG_NET_TGAPP_DEF.h"
//Ӧ�ò�͸����������0x1000-0x1FFF
//#define MSG_TYPE_TGAPP_x              0x1000


//#include "TG_NET_TGC_DEF.h"
//TG���������0x2000-0x2FFF
//#define MSG_TYPE_TGC_x		        0x2000


//#include "TG_NET_TGD_DEF.h"
//TG�����������������0x3000-0x3FFF
//#define MSG_TYPE_TGD_x		        0x3000

#pragma pack(push,4)
typedef struct _tagNET_PACKET_HEAD
{
	UINT8  nHeadCRC;       //ͷУ��
	UINT8  nPriority;      //���ȼ�
	UINT16 nFrameID;       //�����ж����֡��
	UINT32 nFrameSize;     //֡��С
	UINT16 nPacketNum;     //��ǰΪ�ڼ���
	UINT16 nDataLen;       //��ǰ������Ч��ݴ�С
	UINT16 nMsgType;       //MSG type
	union
	{
		UINT16 nFrameNum;      //TG_FRAME_HEAD.nFrameNum
		SINT16 nErrFlag;       //
	};
	
	_tagNET_PACKET_HEAD()
	{
		memset(this,0,sizeof(_tagNET_PACKET_HEAD));
	}

	VOID SetCRC()
	{
		nHeadCRC = 0;
		UINT8 *pTemp = (UINT8*)this;
		for(UINT16 i=1;i<sizeof(_tagNET_PACKET_HEAD);i++)
		{
			nHeadCRC += pTemp[i];
		}
	}
	BOOL CheckCRC()
	{
		UINT8 cCRC = 0;
		UINT8 *pTemp = (UINT8*)this;
		for(UINT16 i=1;i<sizeof(_tagNET_PACKET_HEAD);i++)
		{
			cCRC += pTemp[i];
		}

		return (cCRC == nHeadCRC)?TRUE:FALSE;
	}

}NET_PACKET_HEAD;
#pragma pack(pop)


#endif
